#include "stdio.h"
#include "stdlib.h"
#include <windows.h>
#include "key.h"
#include "Queue.h"

int main()
{
	unsigned short i=0,num=0,keycode=0;
	KeyInit();

	KeySetHardKey(0,1);//key0 off
	KeySetHardKey(1,1);//key1 off
	Sleep(500);

	for(i=0;i<300;i++)
	{
		//chatter test
		if(i==0){
			KeySetHardKey(0,0);//key on
			KeySetHardKey(1,0);//key on
		}
		if(i==1){
			KeySetHardKey(0,1);
			KeySetHardKey(1,1);
		}

		//signle click test
		if(i==10){
			KeySetHardKey(0,0);
			KeySetHardKey(1,0);
		}

		if(i==20){
			KeySetHardKey(0,1);
			KeySetHardKey(1,1);
		}

		//long click
		if(i==100){
			KeySetHardKey(0,0);
			KeySetHardKey(1,0);
		}

		if(i==160){
			KeySetHardKey(0,1);
			KeySetHardKey(1,1);
		}

		//double click
		if(i==170){
			KeySetHardKey(0,0);
			KeySetHardKey(1,0);
		}

		if(i==180){
			KeySetHardKey(0,1);
			KeySetHardKey(1,1);
		}

		if(i==190){
			KeySetHardKey(0,0);
			KeySetHardKey(1,0);
		}

		if(i==200){
			KeySetHardKey(0,1);
			KeySetHardKey(1,1);
		}

		Key_Check_Cyc();
		Sleep(20);
	}

	num=Queue_Num(&SysKeyQueueBuffer);
	printf("There are %d Key Messages\r\n",num);
	for(i=0;i<num;i++)
	{
		keycode=Queue_Pop(&SysKeyQueueBuffer);
		printf("Key Ch:%d,Code:%d\r\n",keycode>>8,keycode&0x00ff);
	}
	system("PAUSE");
}